home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11042 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  80 lines

  1. Path: ix.netcom.com!news
  2. From: ee384@ix.netcom.com(Danny Pham)
  3. Newsgroups: comp.lang.c++
  4. Subject: Need help w/ while loop in "CLASS"!!!
  5. Date: 12 Mar 1996 12:55:02 GMT
  6. Organization: Netcom
  7. Message-ID: <4i3s76$rvg@dfw-ixnews2.ix.netcom.com>
  8. NNTP-Posting-Host: irv-ca13-18.ix.netcom.com
  9. X-NETCOM-Date: Tue Mar 12  6:55:02 AM CST 1996
  10.  
  11. Hi,
  12.     I am really need help on this program. I try to write a program
  13. that involved a link list. But I have a problem with my while loop. The
  14. following is my code:
  15.  
  16. Class Stack
  17. {
  18.     struct linklist
  19.     {
  20.         int Numberlist;
  21.         struct linklist *nextlist;
  22.     };
  23. private:
  24.     |
  25.     |
  26.     |
  27. public:
  28.     Stack();
  29.     ~stack();
  30.     Bool Push(const int &Numberlist);
  31.     Bool Pop(int &Number);
  32.     |
  33.     |
  34. };
  35.  
  36. /////////////////////////
  37. main()
  38. {
  39.     int number, Local, select;
  40.  
  41.     stack mylist;
  42.     mylist.mainmenu();  // menu for user to select push,pop ...
  43.     cin >> select;
  44.     while(select !=5)
  45.     {
  46.         switch(select)
  47.         {
  48.             case 1:
  49.                 while(number = getnumber(&local))
  50.                 {
  51.                     mylist.push(number);
  52.                 }
  53.                 break;
  54.             case 2:
  55.                 |
  56.                 |
  57.         }
  58.         mylist.mainmenu()
  59.         cin >> select;
  60.     }
  61.     return 0;
  62. }
  63.  
  64. //////////////////
  65. int getnumber (int *number)
  66. {
  67.     cout << "please enter a number(Q or q to stop):";
  68.     cin >> *number;
  69.     return *number;
  70. }
  71.  
  72. /////////////////////////
  73. I used a debug program and I found out that when I entered 'q', it
  74. jumped to "mylist.mainmenu() again" and it ran non-stop. Please give me
  75. a hint on this problem.
  76.     Thank you very much !!!!
  77. D.P
  78.  
  79.  
  80.